#include<bits/stdc++.h>
using namespace std;
int dui[2011][2011],idx;
int fa[4000011];
bool mp[2011][2011];
char op;
int find(int x) {return (x == fa[x] ? x : fa[x] = find(fa[x]));}
int ans;
inline void merge(int x,int y)
{
	x = find(x),y = find(y);
	if(x == y) return;
	ans--;
	fa[x] = y;
}
int n,m,Q;
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("unicom.in","r",stdin);
	freopen("unicom.out","w",stdout);
	cin >> n >> m >> Q;
	for(int i = 1;i <= n;i++)
	{
		for(int j = 1;j <= m;j++)
		{
			cin >> op;
			if(op == '1') mp[i][j] = 1;
			dui[i][j] = ++idx;
			fa[idx] = idx;
		}
	}
	while(Q--)
	{
		int u,d,l,r;
		ans = 0;
		cin >> u >> l >> d >> r;
		for(int i = u;i <= d;i++)
		{
			for(int j = l;j <= r;j++)
			{
				fa[dui[i][j]] = dui[i][j];
			}
		}
		for(int i = u;i <= d;i++)
		{
			for(int j = l;j <= r;j++)
			{
				if(!mp[i][j]) continue;
				ans++;
				if(i > u && mp[i - 1][j]) merge(dui[i - 1][j],dui[i][j]);
				if(j > l && mp[i][j - 1]) merge(dui[i][j - 1],dui[i][j]);
			}
		}
		cout << ans << "\n";
	}
	return 0;
}
